/** @file
 *  Example code for osc-control library
 *  This example connects the oscilloscope through
 *  local loopback IP address, and test a number of
 *  basic functions from the library
 */
#include "osc-control.hpp"
#include <iostream>
#include <cstring>
#include <fstream>

using namespace std;

int
main ()
{

  try
  {
//===================================================
    cout << "Connecting to 127.0.0.1[5025]: ";
    osc_control Agilent_DSO90k;
    cout << "OK" << endl;

//===================================================
    cout << "Test if machine is ready: ";
    if (Agilent_DSO90k.testReady ())
      cout << "OK" << endl;
    else
      {
	cout << "FAIL" << endl;
	return 1;
      }
//===================================================
    cout << "Test identify(): ";
    if (Agilent_DSO90k.identify ())
      cout << "OK" << endl;
    else
      cout << "FAIL" << endl;

//===================================================
    cout << "Test number_of_points(): ";
    unsigned Array_length = Agilent_DSO90k.number_of_points ();
    if (Array_length == 1000)
      cout << "OK" << endl;
    else
      cout << "FAIL" << endl;

//===================================================
    cout << "Test preset(): ";
    if (Agilent_DSO90k.preset ())
      cout << "OK" << endl;
    else
      cout << "FAIL" << endl;

//===================================================
    cout << "Test getting single trace..." << endl;
    int8_t *Data = new int8_t[Array_length];

    Agilent_DSO90k.getTrace8 (Data, Array_length);

    cout << "OK\n" << endl;

  }
  catch (std::string e)
  {
    cout << "Error: " << e << endl;
  }
  catch (const char *e)
  {
    cout << "Error: " << e << endl;
  }
  return 0;
}
